package com.xiaoyu.lingdian.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CoreShoppingCart;
import com.xiaoyu.lingdian.service.CoreShoppingCartService;

@Service("coreShoppingCartService")
public class CoreShoppingCartServiceImpl implements CoreShoppingCartService {

	@Autowired
	private MyBatisDAO myBatisDAO;
	
	@Override
	public boolean insertCoreShoppingCart(CoreShoppingCart coreShoppingCart) {
		myBatisDAO.insert(coreShoppingCart);
		return true;
	}

	@Override
	public boolean updateCoreShoppingCart(CoreShoppingCart coreShoppingCart) {
		myBatisDAO.update(coreShoppingCart);
		return true;
	}

	@Override
	public boolean deleteCoreShoppingCart(CoreShoppingCart coreShoppingCart) {
		myBatisDAO.delete(coreShoppingCart);
		return true;
	}

	private static final String DELETE_CORE_ADDRESS_BY_CND = "deleteCoreShoppingCartByCnd";
	
	@Override
	public boolean deleteBatchByIds(List<String> list) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETE_CORE_ADDRESS_BY_CND, hashMap);
		return true;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<CoreShoppingCart> getCoreShoppingCartByUser(String userId) {
		return myBatisDAO.findForList("getCoreShoppingCartByUser", userId);
	}

	@Override
	public boolean deleteCoreShoppingCartByUser(CoreShoppingCart coreShoppingCart) {
		myBatisDAO.delete("deleteCoreShoppingCartByUser", coreShoppingCart);
		return true;
	}

}